package com.ontheroad.mysql.group.service;

import java.util.Date;
import java.util.HashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.modoumama.service.base.impl.BaseServiceImpl;

import com.ontheroad.group.model.LinkageGroupEntity;
import com.ontheroad.group.model.SceneGroupEntity;
import com.ontheroad.group.service.LinkageGroupService;
import com.ontheroad.mysql.group.mapper.LinkageGroupMapper;
import com.ontheroad.mysql.group.mapper.SceneGroupMapper;
import com.ontheroad.utils.UUIDUtil;

/*import com.ontheroad.utils.SmsUtil;*/

/**
 * Created by kedong on 2017/6/25 0021.
 */
@Service
@Transactional
public class LinkageGroupServiceImpl extends
		BaseServiceImpl<LinkageGroupEntity, Integer> implements
		LinkageGroupService {

	private Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	private LinkageGroupMapper linkageGroupMapper;

	@Autowired
	private SceneGroupMapper sceneGroupMapper;

	public HashMap<String, Object> insertLinkageGroup(int sceneId,
			LinkageGroupEntity linkageGroupEntity) throws Exception {
		HashMap<String, Object> bean = new HashMap<String, Object>();
		log.info("添加联动组合信息");
		SceneGroupEntity sceneGroupEntity = new SceneGroupEntity();
		sceneGroupEntity.setSceneId(sceneId);
		sceneGroupEntity.setLinkageId(linkageGroupEntity.getId());
		sceneGroupEntity.setId(UUIDUtil.generate());
		sceneGroupMapper.insertModel(sceneGroupEntity);
		linkageGroupEntity.setCreateTime(new Date());
		linkageGroupMapper.insertModel(linkageGroupEntity);
		bean.put("linkages", linkageGroupEntity);
		return bean;
	}

}
